package com.basics.post.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.basics.api.response.channel.PriseUserData;
import com.basics.post.entity.CyChannelPostPrise;
import com.basics.post.mapper.CyChannelPostPriseMapper;
import com.basics.post.service.CyChannelPostPriseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 帖子点赞 服务实现类
 * </p>
 *
 * @author WangWei
 * @since 2025-03-09
 */
@Service
public class CyChannelPostPriseServiceImpl extends ServiceImpl<CyChannelPostPriseMapper, CyChannelPostPrise> implements CyChannelPostPriseService {

    @Override
    public boolean checkHasPrise(Long userId, String postId){
        return count(new QueryWrapper<CyChannelPostPrise>()
                .eq("user_id",userId).eq("post_id",postId))>0;
    }

    @Override
    public int getPriseNum(Long postId){
        return count(new QueryWrapper<CyChannelPostPrise>().eq("post_id",postId));
    }

    @Override
    public List<PriseUserData> selectPriseList(Long postId, Long limit){
        return baseMapper.selectPriseList(postId,limit);
    }
}
